-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add opt-in rule balanced_xctest_lifecycle #3495
Conversation
Rebased :-) |
name: "Required XCTest Tear Down", | ||
description: "Test classes must implement tearDown when setUp is provided.", | ||
kind: .lint, | ||
nonTriggeringExamples: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add some examples using the class func setUp
and class func tearDown
?
I wonder if it makes sense to check that they're balanced (e.g. a class setUp
requires a class tearDown
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added :-) It does make sense to check if they're balanced. Since they are static methods they have potential to leak to other tests if misused.
FYI |
I'm on the fence about this one. Not sure it's worth it. |
@marcelofabri |
Can you try pushing an empty commit, something in the changelog, etc, to trigger a new build? |
@marcelofabri, done ;-) |
Rebased to resolve a conflict in CHANGELOG.md :-) |
Hi @marcelofabri, can you take a look on this one again? Thanks! |
Hi @marcelofabri, any chance to get this one in the next release? Thanks! |
Hi @jpsim, any chance to get this one merged before the release? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice rule! I do think we should make it a bit more general to handle the inverse case too.
I've just granted you write access to the repo @otaviocc so please merge when you've made those changes (unless they don't make sense for some reason) and CI is green.
Source/SwiftLintFramework/Rules/Lint/RequiredXCTestTearDownRule.swift
Outdated
Show resolved
Hide resolved
Thank you for the access! I'll make the changes and will merge then. |
This PR implements
balanced_xctest_lifecycle
, requested in #3452. This rule enforces test classes to have balanced set-up and tear-down methods.Triggering examples:
Non-triggering examples: